home *** CD-ROM | disk | FTP | other *** search
/ Spanish Scene 1 / SpanishScene1.iso / spanish pack n°1 by llfb / --llfb-- / programas / sources1.dms / sources1.adf / SOURCES / Rutinas_de_lineas / TIP_DrawLine.ASM < prev   
Assembly Source File  |  1996-06-04  |  4KB  |  126 lines

  1. *******************************************************************************
  2. *                                          *
  3. *            'DrawLine V1.01' By TIP/SPREADPOINT              *
  4. *            ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­              *
  5. *                                          *
  6. *******************************************************************************
  7.  
  8. DL_Width    =    40
  9. DL_Fill        =    0        ; 0=NOFILL / 1=FILL
  10.     IFEQ    DL_Fill
  11. DL_MInterns    =    $CA
  12.     ELSE
  13. DL_MInterns    =    $4A
  14.     ENDC
  15.  
  16. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  17. ;    A0 = PlanePtr, A6 = $DFF002, D0/D1 = X0/Y0, D2/D3 = X1/Y1
  18. ;    D4 = PlaneWidth > Kills: D0-D4/A0-A1 (+D5 in Fill Mode)
  19.  
  20. DrawLine:    cmp.w    d1,d3        ; Drawing only from Top to Bottom is
  21.         bge.s    .y1ly2        ; necessary for:
  22.         exg    d0,d2        ; 1) Up-down Differences (same coords)
  23.         exg    d1,d3        ; 2) Blitter Invert Bit (only at top of
  24.                     ;    line)
  25. .y1ly2:        sub.w    d1,d3        ; D3 = yd
  26.  
  27. ; Here we could do an Optimization with Special Shifts
  28. ; depending on the DL_Width value... I know it, but please, let it be.
  29.  
  30.         mulu    d4,d1        ; Use muls for neg Y-Vals
  31.         add.l    d1,a0        ; Please don't use add.w here !!!
  32.         moveq    #0,d1        ; D1 = Quant-Counter
  33.         sub.w    d0,d2        ; D2 = xd
  34.         bge.s    .xdpos
  35.         addq.w    #2,d1        ; Set Bit 1 of Quant-Counter (here it
  36.                     ; could be a moveq)
  37.         neg.w    d2
  38. .xdpos:        moveq    #$f,d4        ; D4 full cleaned (for later oktants
  39.                     ; move.b)
  40.         and.w    d0,d4
  41.     IFNE    DL_Fill
  42.         move.b    d4,d5        ; D5 = Special Fill Bit
  43.         not.b    d5
  44.     ENDC
  45.         lsr.w    #3,d0        ; Yeah, on byte (necessary for bchg)...
  46.         add.w    d0,a0        ; ...Blitter ands automagically
  47.         ror.w    #4,d4        ; D4 = Shift
  48.         or.w    #$B00+DL_MInterns,d4    ; BLTCON0-codes
  49.         swap    d4
  50.         cmp.w    d2,d3        ; Which Delta is the Biggest ?
  51.         bge.s    .dygdx
  52.         addq.w    #1,d1        ; Set Bit 0 of Quant-Counter
  53.         exg    d2,d3        ; Exchange xd with yd
  54. .dygdx:        add.w    d2,d2        ; D2 = xd*2
  55.         move.w    d2,d0        ; D0 = Save for $52(a6)
  56.         sub.w    d3,d0        ; D0 = xd*2-yd
  57.         addx.w    d1,d1        ; Bit0 = Sign-Bit
  58.         move.b    Oktants(PC,d1.w),d4    ; In Low Byte of d4
  59.                         ; (upper byte cleaned above)
  60.         swap    d2
  61.         move.w    d0,d2
  62.         sub.w    d3,d2        ; D2 = 2*(xd-yd)
  63.         moveq    #6,d1        ; D1 = ShiftVal (not necessary) 
  64.                     ; + TestVal for the Blitter
  65.         lsl.w    d1,d3        ; D3 = BLTSIZE
  66.         add.w    #$42,d3
  67.         lea    $52-2(a6),a1    ; A1 = CUSTOM+$52
  68.  
  69. ; WARNING : If you use FastMem and an extreme DMA-Access (e.g. 6
  70. ; Planes and Copper), you should Insert a tst.b (a6) here (for the
  71. ; shitty AGNUS-BUG)
  72.  
  73. .wb:        btst    d1,(a6)        ; Waiting for the Blitter...
  74.         bne.s    .wb
  75.     IFNE    DL_Fill
  76.         bchg    d5,(a0)        ; Inverting the First Bit of Line
  77.     ENDC
  78. ;-------------- Not necessary, only for testing purposes ! (Cf Init Part...)
  79. ;        move.w    #$8000,$74-2(a6)
  80. ;        move.w    #-1,$44-2(a6)
  81. ;        move.w    #-1,$72-2(a6)
  82. ;        move.w    #DL_Width,$60-2(a6)
  83. ;        move.w    #DL_Width,$66-2(a6)
  84. ;--------------
  85.         move.l    d4,$40-2(a6)    ; Writing to the Blitter Regs as fast
  86.         move.l    d2,$62-2(a6)    ; as possible
  87.         move.l    a0,$48-2(a6)
  88.         move.w    d0,(a1)+
  89.         move.l    a0,(a1)+    ; Shit-Word Buffer Ptr...
  90.         move.w    d3,(a1)
  91.         rts
  92. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  93.     IFNE    DL_Fill
  94. SML        =     2
  95.     ELSE
  96. SML        =    0
  97.     ENDC
  98.  
  99. Oktants:    dc.b    SML+1,SML+1+$40
  100.         dc.b    SML+17,SML+17+$40
  101.         dc.b    SML+9,SML+9+$40
  102.         dc.b    SML+21,SML+21+$40
  103. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  104. ;        Optimized Init Part... A6 = $DFF000 > Kills : D0-D2
  105.  
  106. DL_Init:    addq.w    #2,a6        ; A6 = $DFF002 for DrawLine !
  107.         moveq    #-1,d1
  108.     IFGT    DL_Width-127
  109.         move.w    #DL_Width,d0
  110.     ELSE
  111.         moveq    #DL_Width,d0
  112.     ENDC
  113.         moveq    #6,d2
  114. .wb:        btst    d2,(a6)
  115.         bne.s    .wb
  116.         move.w    d1,$44-2(a6)
  117.         move.w    d1,$72-2(a6)
  118.         move.w    #$8000,$74-2(a6)
  119.         move.w    d0,$60-2(a6)
  120.         move.w    d0,$66-2(a6)
  121.         rts
  122.  
  123. DL_Exit:    subq.w    #2,a6        ; A6 = $DFF000
  124.         rts
  125.  
  126.